<?php

	if($authInfo->usertype != '0') {
		redirectCleanly("/");
	}
	
	$gid = extractStringWithKeyFromArray("gid", $_REQUEST);
	if (!$gid) {
		$error = "No Such Group";
		echo "<div id=\"contentIndex\"><p><b><a class=\"link12bold\" href=\"index.php?fileNo=8\">Edit Group</a><br><br></p>".$error."</div>";
	} elseif (in_array($gid, $CMS_PROTECTED_GROUPS)) {
		$error = "This is a Protected Group<br>It cannot be Deleted";
		echo "<div id=\"contentIndex\"><p><b><a class=\"link12bold\" href=\"index.php?fileNo=8\">Edit Group</a><br><br></p>".$error."</div>";
	} else {
?>
<div id="contentIndex">
<?
		$deletenow = extractStringWithKeyFromArray("deletenow", $_REQUEST);
		if (!$deletenow) {
		?>
        <table border="0" cellspacing="0" cellpadding="0" width="300">
		    <tr>
		      <td class="body2-4" colspan="3">
		      <p><b><a class="link12bold" href="index.php?fileNo=8">Edit Group</a><br><br></p>  
		      <p><i>Are you sure you want to delete this group?</i><br><br></b>
		      </td>
		    </tr>
		    <tr>
		      <td class="body2-4" align="right"><b><a href="index.php?fileNo=8">NO</a></b></td>
		      <td width="20">&nbsp;</td>
		      <td class="body2-4" align="left"><b><a href="index.php?fileNo=12&deletenow=true&gid=<?=$gid?>">YES</a></b></td>
		    </tr>		    
                  </table>
		<?
		}
		else {
			$query = "DELETE FROM grouplist WHERE gid=".$gid;
			$db->executeQuery($query);
			$query2 = "DELETE FROM grouplist WHERE gid=".$gid;
			$db->executeQuery($query2);
		?>
                  <table border="0" cellspacing="0" cellpadding="0" width="300">
		    <tr>
		      <td class="body2-4" colspan="3">
		      <p><b><a class="link12bold" href="index.php?fileNo=8">Edit Group</a><br><br></p>  
		      <i>The group was successfully deleted.</i>
		      </td>
		    </tr>		    
                  </table>		
		<?
		}
		?>
</div>
<?
	}
?>